#ifndef __SHADOWSPACE_H__
#define __SHADOWSPACE_H__

#include <standard/reference.h>
#include <standard/vector3.h>
#include <standard/matrix4.h>
#include <standard/texturetarget.h>

class CShadowMaterial;
class CShadowSpace: public CRefObject{
public:
    CShadowSpace();
    virtual ~CShadowSpace();
    bool32 Init( int32 nWidth, int32 nHeight );
    bool32 Final();
    void Update();
    virtual void BeginRender( int32 nViewportWidth, int32 nViewportHeight );
    virtual void EndRender();
    void SetViewPort( float fLeft, float fRight, float fTop, float fBottom, float fNear, float fFar );
    void SetPosition( float x, float y, float z );
    void SetDirectionPos( float x, float y, float z );
    void Move( float x, float y, float z );
    //CShadowMaterial* GetShadowMaterial();
    //Matrix4 GetShadowMatrix();
    //CTextureTarget* GetShadowTexture();

public:
    Ref<CShadowMaterial*> m_rShadowMaterial;
    CMatrix4 projectionMatrix;
    CMatrix4 viewMatrix;
    CMatrix4 worldMatrix;
    CMatrix4 matrixWorldInverse;
    CMatrix4 projScreenMatrix;
    CMatrix4 shadowMatrix;
    float m_fShadowBias;
    float m_fShadowRadius;
    float m_vShadowMapSize[2];
    CVector3 m_tPosition;
    float m_fLeft, m_fRight, m_fTop, m_fBottom, m_fNear, m_fFar;
    CVector3 n_tView;
    CVector3 m_tDirection;
    Ref < CTextureTarget* > m_pTextureDepth;

};





#endif
